<template>
  <div>
    <el-table :data="tableData" stripe border style="width: 100%">
      <el-table-column type="index" label="序号" width="60"> </el-table-column>
      <template v-for="item in tableHead">
        <el-table-column
          v-if="item.columnType === 'slot'"
          :prop="item.field"
          :label="item.label"
          :key="item.field"
          :width="item.width"
          :align="align"
          :fixed="item.fixed"
        >
          <template slot-scope="scope">
            <slot :name="item.slotName" :elscope="scope" />
          </template>
        </el-table-column>
        <el-table-column
          v-else
          :prop="item.field"
          :label="item.label"
          :key="item.field"
          :width="item.width"
          :align="align"
          :fixed="item.fixed"
        ></el-table-column>
      </template>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "pg-el-table",
  props: {
    tableHeadConfig: {
      type: Array,
      default: () => {
        return [
          {
            label: "skuId",
            field: "skuId",
          },
          {
            label: "商品名称",
            field: "skuName",
          },
          {
            label: "操作",
            columnType: "slot",
            slotName: "operation",
          },
        ];
      },
    },
    tableLoadData: {
      type: Array,
      default: () => {
        return [
          {
            skuId: "111skuId",
            skuName: "222商品名称",
          },
        ];
      },
    },
    align: {
      type: String,
      default: "left",
    },
  },
  methods: {
    // selectLine() {
    //   if (
    //     this.$refs.dataTable.selection &&
    //     this.$refs.dataTable.selection.length > 0
    //   ) {
    //     this.$emit("selectLine", this.$refs.dataTable.selection);
    //   }
    // },
  },
  computed: {
    tableData() {
      return this.tableLoadData;
    },
    tableHead() {
      return this.tableHeadConfig;
    },
  },

  created() {



      
  },
};
</script>

<style>
</style>